﻿Imports System.Data.OleDb

Public Class AddMoneyJunction
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Not IsPostBack) Then
            bindmoneydata()
            bindtag()
        End If
    End Sub
    Protected Sub Button3_Click(sender As Object, e As EventArgs)
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString004").ConnectionString)
        Dim SqlString As String = "Insert into  sms_moneytagjunction ( sms_moneydata_fkid, sms_tag_fkid)values(@moneydata,@tag )"

        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)

        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@moneydata", ddl_moneydata.SelectedValue)
        cmd.Parameters.AddWithValue("@tag", ddl_tag.SelectedValue)

        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        ddl_moneydata.SelectedValue = "0"
        ddl_tag.SelectedValue = "0"
        ScriptManager.RegisterClientScriptBlock( _
              Me, _
              GetType(Page), _
              "script", _
              "returnempcode();", _
              True)

    End Sub

    '<System.Web.Services.WebMethod>
    'Private Sub Disable(value As String, url As String)

    'End Sub
    Protected Sub bindmoneydata()
        Try
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString001").ConnectionString)
            Dim SqlString As String = "select * from sms_moneydata"

            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
            cmd.CommandType = CommandType.Text
            oleDbConn.Open()
            Dim sda As OleDbDataAdapter = New OleDbDataAdapter(cmd)
            Dim ds As DataSet = New DataSet()
            sda.Fill(ds)
            ddl_moneydata.DataTextField = "Company_Name"
            ddl_moneydata.DataValueField = "ID"
            ddl_moneydata.DataSource = ds
            ddl_moneydata.DataBind()
            ddl_moneydata.Items.Insert(0, New ListItem("--Select--", "0"))
        Catch ex As Exception

        End Try
    End Sub
    Protected Sub bindtag()
        Try
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString001").ConnectionString)
            Dim SqlString As String = "select * from sms_tags"

            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
            cmd.CommandType = CommandType.Text
            oleDbConn.Open()
            Dim sda As OleDbDataAdapter = New OleDbDataAdapter(cmd)
            Dim ds As DataSet = New DataSet()
            sda.Fill(ds)
            ddl_tag.DataTextField = "Tag"
            ddl_tag.DataValueField = "ID"
            ddl_tag.DataSource = ds
            ddl_tag.DataBind()
            ddl_tag.Items.Insert(0, New ListItem("--Select--", "0"))
        Catch ex As Exception

        End Try
    End Sub
End Class